<#setting classic_compatible=true> <#assign
	base=request.contextPath /> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="${base}/zhgl-jzstyxx-manage/css/messagePandect/messagePandect.css">
<link rel="stylesheet" type="text/css" href="${base}/zhgl-jzstyxx-manage/css/overview/overView.css"> 
<link rel="stylesheet" type="text/css" href="${base}/zhgl-jzstyxx-manage/css/system/changePassword.css"> 
<title>统一消息中心</title>
<!-- 引入通用css -->
<#include "/common/commoncss.ftl">
</head>

<body>
	<!-- 标题栏区域 -->
	<div class="titleColumn">
		<!-- <span class="iconfont icon-peizhi"></span><span id="messagePan" style="margin-left: 20px;">修改密码</span> -->
		<span class="iconfont icon-peizhi"></span><span style="margin-left:20px;">系统管理</span>&nbsp;&nbsp;<span class="fa fa-angle-right"></span>&nbsp;&nbsp;<span id="messagePan">修改密码</span>
	</div>
	
	<!-- 正文区域 -->
	<div class="contentTable">
		<div id="form" >
			<div class="float">
				<span class="firstleft">用户名：</span>
				<span class="secondright" id="use"></span>
			</div>
			<div class="float">
				<span class="firstleft">请输入原密码*：</span>
				<span class="secondright"><input class="inp" id="oldpwd" type="password" onfocus="mesremove()"/><span class="fa fa-eye-slash" id="eye" onmouseover="openeye()" onmouseout="closeeys()"></span></span>
				<span class="mes" id="mesold"></span>
			</div>
			<div class="float">
				<span class="firstleft">请输入新密码*：</span>
				<span class="secondright"><input class="inp" id="newpwd" placeholder="请输入六位数密码" onblur="jiaoyan()" onfocus="jiaoyanremove()" type="password"/><span class="fa fa-eye-slash" id="eye1" onmouseover="openeye1()" onmouseout="closeeys1()"></span></span>
				<span class="mes" id="newmes"></span>
			</div>
			<div class="float">
				<span class="firstleft"><input class="butt" onclick="commits()" type="button" value="确认修改"></span>
				<span class="secondright"><input class="butt" type="reset" value="重新填写"></span>
			</div>
		</div>
	
	</div>


	<!-- 引入通用和js -->
	<#include "/common/commonjs.ftl"> 
	
	<!-- <script type="text/javascript" src="${base}/zhgl-jzstyxx-manage/js/overview/jquery-1.8.3.min.js"></script> -->
	<script type="text/javascript" src="${base}/zhgl-jzstyxx-manage/js/login/jquery.cookie.js"></script> 
	<script type="text/javascript" src="${base}/zhgl-jzstyxx-manage/js/login/jquery.session.js"></script> 
	
	<script type="text/javascript">
		//查询session中登录时绑定的用户名
		var username=$.session.get("username");
		$(document).ready(function(){
			$("#use").html(username);
		});
		//显示旧密码
		function openeye(){
			$("#eye").removeClass("fa-eye-slash");
			$("#eye").addClass("fa-eye");
			$("#oldpwd").attr("type","text");
		}
		//显示新密码
		function openeye1(){
			$("#eye1").removeClass("fa-eye-slash");
			$("#eye1").addClass("fa-eye");
			$("#newpwd").attr("type","text");
		}
		//加密旧密码
		function closeeys(){
			$("#eye").removeClass("fa-eye");
			$("#eye").addClass("fa-eye-slash");
			$("#oldpwd").attr("type","password");
		}
		//加密新密码
		function closeeys1(){
			$("#eye1").removeClass("fa-eye");
			$("#eye1").addClass("fa-eye-slash");
			$("#newpwd").attr("type","password");
		}
		//校验新密码
		function jiaoyan(){
			var newpwd=$("#newpwd").val();
			if(newpwd!=null&&newpwd!=undefined){
				if(newpwd.length>6||newpwd.length<6){
					$("#newmes").html("长度不符合要求");
				}
			}
		}
		//校验
		function jiaoyanremove(){
			$("#newmes").html("");
		}
		//修改旧密码内容是,mse隐藏
		function mesremove(){
			$("#mesold").html("");
		}
		//点击确认修改按钮
		function commits(){
			var oldpwd=$("#oldpwd").val();
			console.log("oldpwd:"+oldpwd);
			var pwd=$.session.get("password");
			console.log("pwd:"+pwd);
			if(oldpwd!=pwd){
				$("#mesold").html("密码不正确");
				$("#mesold").show();
			}
			//旧密码正确
			if(oldpwd==pwd){
				//新密码
				var newpwd=$("#newpwd").val();
				var username=$.session.get("username");
				var d={"username":username,"newpwd":newpwd};
				if(newpwd.length!=6){
					$("#newmes").html("密码格式不正确");
				}else{
					//去修改密码
					$.ajax({
						"type":"POST",
						"url":"../user/changePassword",
						"dataType":"json",
						"data":{"user":username,"pwd":newpwd},
						"success":function(obj){
							if(obj!=null){
								alert("密码修改成功，请重新登录");
								top.location.href="/zhgl-jzstyxx-manage/user/toLogin";
							}
						}
					});
				}
			}
			
		}
	</script>

</body>
</html>